home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / m68k / amigados.h < prev    next >
C/C++ Source or Header  |  1995-08-24  |  17KB  |  454 lines

  1. /* Definitions of target machine for GNU compiler.  amiga 68000/68020 version.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Contributed by Markus M. Wild (wild@amiga.physik.unizh.ch).
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Phil.B 12-Mar-95: Define USE_GAS if GCC is supposed to work with the GNU
  22.    assembler, GNU linker and GNU debugger using DBX debugging information. */
  23.  
  24. #define USE_GAS
  25.  
  26. /* Control assembler-syntax conditionals in m68k.md.  */
  27.  
  28. #ifndef USE_GAS
  29. #define MOTOROLA        /* Use Motorola syntax rather than "MIT" */
  30. #endif /* !USE_GAS */
  31.  
  32. #include "m68k/m68k.h"
  33.  
  34. /* See m68k.h for bits in TARGET_DEFAULT.
  35.    0 means 68000, no hardware fpu (68881/68882/68040).
  36.    7 means 68020 (or higher) with hardware fpu.  */
  37.  
  38. #ifndef TARGET_DEFAULT
  39. #define TARGET_DEFAULT 0
  40. #endif
  41.  
  42. /* Define __HAVE_68881__ in preprocessor according to the -m flags.
  43.    This will control the use of inline 68881 insns in certain macros.
  44.    Also inform the program which CPU this is for.  */
  45.  
  46. #if TARGET_DEFAULT & 02
  47.  
  48. /* -m68881 is the default */
  49. #define CPP_SPEC \
  50. "%{!msoft-float:-D__HAVE_68881__ }\
  51. %{!ansi:%{m68000:-Dmc68010}%{mc68000:-Dmc68010}%{m68030:-Dmc68030}%{mc68030:-Dmc68030}%{m68040:-Dmc68040}\
  52. %{mc68040:-Dmc68040}%{!mc68000:%{!m68000:-Dmc68020}}}"
  53.  
  54. #else
  55.  
  56. /* -msoft-float is the default, assume -mc68000 as well */
  57. #define CPP_SPEC \
  58. "%{m68881:-D__HAVE_68881__ }\
  59. %{!ansi:%{m68020:-Dmc68020}%{mc68020:-Dmc68020}%{m68030:-Dmc68030}%{mc68030:-Dmc68030}%{m68040:-Dmc68040}\
  60. %{mc68040:-Dmc68040}%{!mc68020:%{!m68020:%{!mc68030:%{!m68030:%{!mc68040:%{!m68040:-Dmc68010}}}}}}}"
  61.  
  62. /* Don't try using XFmode since we don't have appropriate runtime software
  63.    support.  */
  64. #undef LONG_DOUBLE_TYPE_SIZE
  65. #define LONG_DOUBLE_TYPE_SIZE 64
  66.  
  67. #endif
  68.  
  69. /* -m68000 requires special flags to the assembler.  */
  70.  
  71. #define ASM_SPEC \
  72.  "%{m68000:-mc68010} %{mc68000:-mc68010} %{m68020:-mc68020} %{mc68020:-mc68020} %{m68030:-mc68030} %{mc68030:-mc68030} \
  73. %{m68040:-mc68040} %{mc68040:-mc68040} %{m68020-40:-mc68020} %{mc68020-40:-mc68020} \
  74. %{!mc68000:%{!m68000:%{!mc68020:%{!m68020:%{!mc68030:%{!m68030:%{!mc68040:%{!m68040:%{!m68020-40:%{!mc68020-40:-mc68010}}}}}}}}}} %{msmall-code:-l}"
  75.  
  76. /* amiga/amigados are the new "standard" defines for the Amiga, MCH_AMIGA
  77.  * was used before and is included for compatibility reasons */
  78.  
  79. #define CPP_PREDEFINES "-Dmc68000 -Damiga -Damigados -DMCH_AMIGA -DAMIGA -Asystem(amigados) -Acpu(m68k) -Amachine(m68k)"
  80.  
  81. /* Choose the right startup file, depending on whether we use base relative
  82.    code, base relative code with automatic relocation (-resident), or plain
  83.    crt0.o. 
  84.   
  85.    Profiling is currently only available for plain startup.
  86.    mcrt0.o does not (yet) exist. */
  87.  
  88. #define STARTFILE_SPEC \
  89.  "%{!noixemul:%{resident:rcrt0.o%s}%{!resident:%{!fbaserel:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}\
  90. %{fbaserel:%{pg:bgcrt0.o%s}%{!pg:%{p:bmcrt0.o%s}%{!p:bcrt0.o%s}}}}}\
  91. %{noixemul:%{resident:libnix/nrcrt0.o%s}%{!resident:%{fbaserel:libnix/nbcrt0.o%s}%{!fbaserel:libnix/ncrt0.o%s}}}"
  92.  
  93. #define ENDFILE_SPEC "%{noixemul:-lstubs}"
  94.  
  95. /* Automatically search libamiga.a for AmigaDOS specific functions.  Note
  96.    that we first search the standard C library to resolve as much as
  97.    possible from there, since it has names that are duplicated in libamiga.a
  98.    which we *don't* want from there.  Then search the standard C library
  99.    again to resolve any references that libamiga.a might have generated.
  100.    This may only be a temporary solution since it might be better to simply
  101.    remove the things from libamiga.a that should be pulled in from libc.a
  102.    instead, which would eliminate the first reference to libc.a. */
  103.  
  104. #define LIB_SPEC "%{!noixemul:%{!p:%{!pg:-lc -lamiga -lc}}%{p:-lc_p}%{pg:-lc_p}}%{noixemul:-lnixmain -lnix -lamiga}"
  105.  
  106. /* if debugging, tell the linker to output amiga-hunk symbols *and* a BSD
  107.    compatible debug hunk (which will probably change in the future, it's not
  108.    tremendously useful in its current state). */
  109.  
  110. #define LINK_SPEC "%{noixemul:-shortdata -fl libnix} %{fbaserel:%{!resident:-databss-together -fl libb}}\
  111. %{resident:-databss-together -datadata-reloc -fl libb} %{g:-amiga-debug-hunk} \
  112. %{m68020:-fl libm020} %{m68030:-fl libm020} %{m68040:-fl libm020} %{m68020-40:-fl libm020} %{m68881:-fl libm881}\
  113. %{mc68020:-fl libm020} %{mc68030:-fl libm020} %{mc68040:-fl libm020} %{mc68020-40:-fl libm020} %{mc68881:-fl libm881}"
  114.  
  115. #define CC1_SPEC "%{m68040:-mbitfield }%{mc68040:-mbitfield }%{resident:-fbaserel }%{msmall-code:-fno-function-cse }%{!noixemul:-mfixedstack} "
  116.  
  117. #define CC1PLUS_SPEC "%{m68040:-mbitfield }%{mc68040:-mbitfield }%{resident:-fbaserel }%{msmall-code:-fno-function-cse }%{!noixemul:-mfixedstack} "
  118.  
  119. /* Omit frame pointer at high optimization levels. (This doesn't hurt, since
  120.    GDB doesn't work under AmigaDOS at the moment anyway..) */
  121.   
  122. #define OPTIMIZATION_OPTIONS(OPTIMIZE) \
  123. {                                  \
  124.   if (OPTIMIZE >= 2)                         \
  125.     flag_omit_frame_pointer = 1;                \
  126. }
  127.  
  128. /* provide a dummy entry for the small-code switch. This is currently only
  129.    needed by the assembler (explanations: m68k.h), but will be used by cc1
  130.    to output 16bit pc-relative code later.
  131.    PhB 21-Jun-95: use now SUBTARGET_SWITCHES instead of redefining
  132.    whole TARGET_SWITCHES, means that all additions made to m68k.* are
  133.    now taken into account */
  134.  
  135. #undef SUBTARGET_SWITCHES
  136. #define SUBTARGET_SWITCHES  \
  137.     { "small-code", 0 },/* Affects *_SPEC and/or GAS.  */    \
  138.     { "stackcheck", 02000},            \
  139.     { "nostackcheck", -02000},            \
  140.     { "stackextend", 04000},            \
  141.     { "nostackextend", -04000},            \
  142.     { "fixedstack", -04200},
  143.  
  144. #define TARGET_STACKCHECK    (target_flags&02000)
  145. #define TARGET_STACKEXTEND    (!TARGET_STACKCHECK&&(target_flags&04000))
  146.  
  147. /* Every structure or union's size must be a multiple of 2 bytes.  */
  148.  
  149. #define STRUCTURE_SIZE_BOUNDARY 16
  150.  
  151. /* This is (almost;-)) BSD, so it wants DBX format.  */
  152.  
  153. #define DBX_DEBUGGING_INFO
  154.  
  155. /* Allow folding division by zero.  */
  156. #define REAL_INFINITY
  157.  
  158. /* The following was hacked into final.c, to allow some notice of
  159.  * source line and filename to be injected into the assembly code,
  160.  * even if not using one of the "approved" debuggers (albaugh@agames.com).
  161.  */
  162. #if 0
  163. #define ASM_NOTE_SOURCE_LINE(FILE, LINE, FILENAME)\
  164.   fprintf(file,"*#line %d \"%s\"\n",(LINE),(FILENAME))
  165. #endif
  166.  
  167. #if 0    /* This apparently is no longer necessary? */
  168.  
  169. /* This is how to output an assembler line defining a `double' constant.  */
  170.  
  171. #undef ASM_OUTPUT_DOUBLE
  172. #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                    \
  173.   {                                    \
  174.     if (REAL_VALUE_ISINF (VALUE))                    \
  175.       fprintf (FILE, "\t.double 0r%s99e999\n", (VALUE) > 0 ? "" : "-");    \
  176.     else if (isnan (VALUE))                        \
  177.       {                                    \
  178.     union { double d; long l[2];} t;                \
  179.     t.d = (VALUE);                            \
  180.     fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", t.l[0], t.l[1]); \
  181.       }                                    \
  182.     else                                \
  183.       fprintf (FILE, "\t.double 0r%.17g\n", VALUE);            \
  184.   }
  185.  
  186. /* This is how to output an assembler line defining a `float' constant.  */
  187.  
  188. #undef ASM_OUTPUT_FLOAT
  189. #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
  190.   {                                    \
  191.     if (REAL_VALUE_ISINF (VALUE))                    \
  192.       fprintf (FILE, "\t.single 0r%s99e999\n", (VALUE) > 0 ? "" : "-");    \
  193.     else if (isnan (VALUE))                        \
  194.       {                                    \
  195.     union { float f; long l;} t;                    \
  196.     t.f = (VALUE);                            \
  197.     fprintf (FILE, "\t.long 0x%lx\n", t.l);                \
  198.       }                                    \
  199.     else                                \
  200.       fprintf (FILE, "\t.single 0r%.9g\n", VALUE);            \
  201.   }
  202.  
  203. /* This is how to output an assembler lines defining floating operands.
  204.    There's no way to output a NaN's fraction, so we lose it.  */
  205.   
  206. #undef ASM_OUTPUT_FLOAT_OPERAND
  207. #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE)                \
  208.  do {                                \
  209.       if (CODE == 'f')                        \
  210.         {                            \
  211.           (REAL_VALUE_ISINF ((VALUE))                        \
  212.            ? asm_fprintf (FILE, "%I0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  213.            : (VALUE) == -0.0                            \
  214.            ? asm_fprintf (FILE, "%I0r-0.0")                    \
  215.            : asm_fprintf (FILE, "%I0r%.9g", (VALUE))) \
  216.         } else {                                        \
  217.           long l;                        \
  218.           REAL_VALUE_TO_TARGET_SINGLE (VALUE, l);        \
  219.           if (sizeof (int) == sizeof (long))            \
  220.             asm_fprintf ((FILE), "%I0x%x", l);            \
  221.           else                            \
  222.             asm_fprintf ((FILE), "%I0x%lx", l);            \
  223.         }                            \
  224.      } while (0)
  225.  
  226. #undef ASM_OUTPUT_DOUBLE_OPERAND
  227. #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                \
  228.   (REAL_VALUE_ISINF ((VALUE))                        \
  229.    ? asm_fprintf (FILE, "%I0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  230.    : (VALUE) == -0.0                            \
  231.    ? asm_fprintf (FILE, "%I0r-0.0")                    \
  232.    : asm_fprintf (FILE, "%I0r%.17g", (VALUE)))
  233.  
  234. #endif    /* 0 */
  235.  
  236. /* use A5 as framepointer instead of A6, this makes A6 available as a
  237.    general purpose register, and can thus be used without problems in
  238.    direct library calls. */
  239.  
  240. #undef FRAME_POINTER_REGNUM
  241. #define FRAME_POINTER_REGNUM 13
  242. #undef ARG_POINTER_REGNUM
  243. #define ARG_POINTER_REGNUM 13
  244.  
  245. /* we use A4 for this, not A5, which is the framepointer */
  246. #undef PIC_OFFSET_TABLE_REGNUM
  247. #define PIC_OFFSET_TABLE_REGNUM 12
  248.  
  249. /* setup a default shell return value for those (gazillion..) programs that
  250.    (inspite of ANSI-C) declare main() to be void (or even VOID...) and thus
  251.    cause the shell to randomly caugh upon executing such programs (contrary
  252.    to Unix, AmigaDOS scripts are terminated with an error if a program returns
  253.    with an error code above the `error' or even `failure' level
  254.    (which is configurable with the FAILAT command) */
  255.  
  256. #define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
  257.  
  258. /* we do have an ansi-compliant c-library ;-) */
  259. #define HAVE_VPRINTF
  260. #define HAVE_VFPRINTF
  261. #define HAVE_PUTENV
  262. #define HAVE_STRERROR
  263. #define HAVE_ATEXIT
  264.  
  265. /* given that symbolic_operand(X), return TRUE if no special
  266.    base relative relocation is necessary */
  267.  
  268. #define LEGITIMATE_BASEREL_OPERAND_P(X) \
  269.   (flag_pic >= 3 && read_only_operand (X))
  270.  
  271. #undef LEGITIMATE_PIC_OPERAND_P
  272. #define LEGITIMATE_PIC_OPERAND_P(X) \
  273.   (! symbolic_operand (X, VOIDmode) || LEGITIMATE_BASEREL_OPERAND_P (X))
  274.  
  275. /* Phil.B 12-Mar-95: check if this would fix some PIC problems */
  276. /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
  277.    operand of a function call. */
  278. /* #undef LEGITIMATE_PIC_OPERAND_P
  279. #define LEGITIMATE_PIC_OPERAND_P(X) \
  280.   (! symbolic_operand (X, VOIDmode) \
  281.    || ((GET_CODE(X) == SYMBOL_REF) && SYMBOL_REF_FLAG(X)))
  282. */
  283.  
  284. /* Define this macro if references to a symbol must be treated
  285.    differently depending on something about the variable or
  286.    function named by the symbol (such as what section it is in).
  287.  
  288.    The macro definition, if any, is executed immediately after the
  289.    rtl for DECL or other node is created.
  290.    The value of the rtl will be a `mem' whose address is a
  291.    `symbol_ref'.
  292.  
  293.    The usual thing for this macro to do is to a flag in the
  294.    `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
  295.    name string in the `symbol_ref' (if one bit is not enough
  296.    information).
  297.  
  298.    On the Amiga we use this to indicate if a symbol is in text or
  299.    data space.  */
  300.  
  301. #define ENCODE_SECTION_INFO(DECL)                    \
  302. do                                    \
  303.   {                                    \
  304.     if (TREE_CODE (DECL) == FUNCTION_DECL)                \
  305.       SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;            \
  306.     else                                \
  307.       {                                    \
  308.     rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'        \
  309.            ? TREE_CST_RTL (DECL) : DECL_RTL (DECL));        \
  310.     if (flag_pic >= 3 &&                         \
  311.         (TREE_CODE (DECL) == STRING_CST && !flag_writable_strings))    \
  312.       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;                \
  313.     else if (flag_pic < 3 &&                    \
  314.          RTX_UNCHANGING_P (rtl) && !MEM_VOLATILE_P (rtl))    \
  315.       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;                \
  316.       }                                    \
  317.   }                                    \
  318. while (0)
  319.  
  320. #undef SELECT_RTX_SECTION
  321. #define SELECT_RTX_SECTION(MODE, X) readonly_data_section ();
  322.  
  323. /* according to varasm.c, RELOC referrs *only* to whether constants (!)
  324.    are addressed by address. This doesn't matter in baserelative code,
  325.    so we allow (inspite of flag_pic) readonly_data_section() in that
  326.    case */
  327.  
  328. #undef SELECT_SECTION
  329. #define SELECT_SECTION(DECL, RELOC)                    \
  330. {                                    \
  331.       if ((TREE_CODE (DECL) == STRING_CST) && !flag_writable_strings)    \
  332.     readonly_data_section ();                    \
  333.       else if (flag_pic < 3                        \
  334.       && TREE_READONLY (DECL)                    \
  335.       && ! TREE_THIS_VOLATILE (DECL)                \
  336.       && DECL_INITIAL (DECL)                    \
  337.       && (DECL_INITIAL (DECL) == error_mark_node            \
  338.           || TREE_CONSTANT (DECL_INITIAL (DECL)))            \
  339.       && ! (flag_pic && RELOC))                    \
  340.     readonly_data_section ();                    \
  341.       else                                \
  342.     data_section ();                        \
  343. }
  344.  
  345.  
  346.  
  347. #if not_yet_working
  348.  
  349. /* starting support for amiga specific keywords
  350.  * --------------------------------------------
  351.  */
  352.  
  353. /* validate attributes that don't take a parameter. Currently we support
  354.  * __attribute__ (saveds) and __attribute__ (interrupt)
  355.  */
  356. #define HANDLE_ATTRIBUTE0(attr) \
  357.   (strcmp(attr, "saveds") != 0 && strcmp(attr, "interrupt") != 0)
  358.  
  359. /* (c-common.c)
  360.  * install additional attributes
  361.  */
  362. #define HANDLE_EXTRA_ATTRIBUTES(a)                         \
  363.   if (TREE_VALUE (a) != 0                            \
  364.       && TREE_CODE (TREE_VALUE (a)) == IDENTIFIER_NODE                \
  365.       && TREE_VALUE (a) == get_identifier ("saveds"))                \
  366.     {                                        \
  367.       if (TREE_CODE (decl) != FUNCTION_DECL)                    \
  368.         {                                    \
  369.           warning_with_decl (decl,                        \
  370.               "saveds attribute specified for non-function `%s'");        \
  371.       return;                                \
  372.         }                                    \
  373.                                               \
  374.       attr_do_saveds (DECL_NAME (decl));                    \
  375.     }                                        \
  376.   else if (TREE_VALUE (a) != 0                            \
  377.       && TREE_CODE (TREE_VALUE (a)) == IDENTIFIER_NODE                \
  378.       && TREE_VALUE (a) == get_identifier ("interrupt"))            \
  379.     {                                        \
  380.       if (TREE_CODE (decl) != FUNCTION_DECL)                    \
  381.         {                                    \
  382.           warning_with_decl (decl,                        \
  383.               "saveds attribute specified for non-function `%s'");        \
  384.       return;                                \
  385.         }                                    \
  386.                                               \
  387.       attr_do_interrupt (DECL_NAME (decl));                    \
  388.     }                                        \
  389.  
  390.  
  391. #define PROLOGUE_EXTRA_SAVE(mask)                        \
  392.   { extern char *current_function_name;                        \
  393.     /* saveds makes the function preserve d1/a0/a1 as well */            \
  394.     if (attr_does_saveds (current_function_name))                \
  395.       mask |= 0x40c0; }                                \
  396.  
  397.  
  398. #define EPILOGUE_EXTRA_RESTORE(mask, nregs)                    \
  399.   { extern char *current_function_name;                        \
  400.     /* restore those extra registers */                        \
  401.     if (attr_does_saveds (current_function_name))                \
  402.       {                                        \
  403.     mask |= 0x0302;                                \
  404.     nregs += 3;                                \
  405.       } }                                    \
  406.  
  407.  
  408. #define EPILOGUE_EXTRA_BARRIER_KLUDGE(stream)                    \
  409.   { extern char *current_function_name;                        \
  410.     /* PLEASE Help! how is this done cleaner?? */                \
  411.     if (attr_does_saveds (current_function_name))                \
  412.       {                                        \
  413.     fprintf (stderr,                             \
  414.          "warning: couldn't cleanup `saveds'-stack in `%s'.\n");    \
  415.     fprintf (stderr,                            \
  416.          "         this is only ok, if the function never returns!\n");    \
  417.       }    }                                    \
  418.         
  419.  
  420. #define EPILOGUE_EXTRA_TEST(stream)                        \
  421.   { extern char *current_function_name;                        \
  422.     /* with the interrupt-attribute, we have to set the cc before rts */    \
  423.     if (attr_does_interrupt (current_function_name))                \
  424.       asm_fprintf (stream, "\ttstl %s\n", reg_names[0]); }            \
  425.  
  426. #endif
  427.  
  428.  
  429. /*
  430.  * Support for automatic stack extension.
  431.  */
  432.  
  433. #define HAVE_restore_stack_nonlocal 1
  434. #define gen_restore_stack_nonlocal \
  435. (TARGET_STACKEXTEND?gen_stack_cleanup_call:gen_move_insn)
  436.  
  437. #define HAVE_restore_stack_function 1
  438. #define gen_restore_stack_function gen_restore_stack_nonlocal
  439.  
  440. #define HAVE_restore_stack_block 1
  441. #define gen_restore_stack_block gen_restore_stack_nonlocal
  442.  
  443. /* Reserve PIC_OFFSET_TABLE_REGNUM (a5) for doing PIC relocation if position
  444.    independent code is being generated, by making it a fixed register. */
  445.  
  446. #define CONDITIONAL_REGISTER_USAGE            \
  447. {                            \
  448.   if (flag_pic)                        \
  449.     fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;        \
  450.   /* prevent saving/restoring of the base reg */    \
  451.   if (flag_pic == 3)                    \
  452.     call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;    \
  453. }
  454.